﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace UtilWpf.Extensions
{
    /// <summary>
    /// 
    /// </summary>
    public static class ComboBoxExtend
    {
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="combobox"></param>
        public static void ComboBoxBindEnum<T>(this ComboBox combobox) where T : Enum
        {
            foreach (T item in Enum.GetValues(typeof(T)))
            {
                combobox.Items.Add(item);
            }
            if (combobox.Items.Count > 0)
            {
                combobox.SelectedIndex = 0;
            }
        }

    }
}
